<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        button {
            padding: 10px 20px;
            cursor: pointer;
        }

        div {
            width: 100px;
            height: 100px;
            background-color: #ccc;
            font-size: 50px;
            margin: 10px 0 0 0 ;
        }
    </style>
</head>
<body>
    <button>点击删除一个元素</button>
    <div>1</div>
    <div id="demo">2</div>
    <div>3</div>

    <script>
        // 动态获取
        var elements = document.getElementsByTagName("div");
        console.log(elements);

        // 静态获取
        var aDiv = document.querySelectorAll("div");
        console.log(aDiv);


        // 绑定事件(点击按钮删除第二个div标签)
        document.querySelector("button").onclick = function(){
            var ele = document.getElementById("demo");
            ele.remove();
        }


    </script>
</body>
</html>